package fileAndIO;

import org.junit.Test;

import java.io.*;

// 字符流
public class Test3 {
    @Test
    public void test1() throws IOException {
        // 读
        Reader reader = new FileReader("C:\\Users\\83726\\ccc\\aa.txt");
        char[] chars = new char[1024];
        int len;
        while ((len = reader.read(chars)) != -1) {
            System.out.print(new String(chars, 0, len));
        }
        reader.close();
    }

    @Test
    public void test2() throws IOException {
        // 写
        Writer writer = new FileWriter("C:\\Users\\83726\\ccc\\aa.txt");
        writer.write("YUYUDEQIU\n");
        writer.write("YUYUDEQIU\n");
        writer.write("YUYUDEQIU\n");
        writer.write("YUYUDEQIQ\n");
        writer.close();
    }
}
